package com.pug.job.config;

import com.pug.job.task.QuartzJobPrintOutTask;
import org.quartz.*;
import org.springframework.context.annotation.Bean;

/**
 * @author RenGaoshuai
 * @date 2023/7/5 14:28
 * @description QuartzJob配置
 */
//@Configuration
public class QuartzJobConfig {

    @Bean
    public JobDetail jobDetail(){
        JobDetail jobDetail = JobBuilder.newJob(QuartzJobPrintOutTask.class)
                .withIdentity("job1", "group1")
                .storeDurably()
                .build();
        return jobDetail;
    }

    @Bean
    public Trigger trigger(){
        Trigger trigger = TriggerBuilder.newTrigger()
                .forJob(jobDetail())
                .withIdentity("trigger1", "group1")
                .startNow()
                .withSchedule(CronScheduleBuilder.cronSchedule("*/20 * * * * ?"))
                .build();
        return trigger;
    }
}
